<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>图片监控</title>
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
  </head>
  <body>
  	<?# if(!empty($studio)) {#?>
    <div class="collapse navbar-collapse" style="color:red;">
      已下线设为怀疑的主播:<?#=$studio;#?>
   </div>
    <?#}#?>
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
		<form class="navbar-form navbar-left">
		  <a href="<?#=$baseurl;#?>"><button type="button" class="btn btn-success">刷新</button></a>
		  <button type="button" class="btn btn-info" id="set">设为怀疑</button>
		  <button type="button" class="btn btn-info" id="cancel">取消怀疑</button>
	      <div class="form-group">
	         <label>主播名字/直播标题:</label> <input type="text" name="key" value="<?#=$key;#?>" class="form-control" placeholder="主播名字/直播标题">
	      </div>&nbsp;&nbsp;
	      <div class="form-group">
	         <label>状态:</label> 
	         <select name="status" class="form-control">
	           <option value=""></option>
	           <option value="1" <?#if($status==1){#?>selected<?#}?>>已标记</option>
	           <option value="0" <?#if(is_numeric($status) && $status==0){#?>selected<?#}?>>正常</option>
	         </select>
	      </div>
	      <button type="submit" class="btn btn-default">Submit</button>
	    </form>
    </div>
    <div id="list" style="margin:0 10px 0 10px;">
        <div class="row">
		  <?#
		  if (!empty($list)) {
		    foreach ($list as $item) {
          #?>
		  <div class="col-xs-6 col-md-3">
			<a href="<?#=$item['link'];#?>" target="_blank" class="thumbnail">
			  <img src="<?#=$item['thumb'];#?>" data-holder-rendered="true" style="height: 180px; width: 100%;">
			</a>
			<p align="center">
			  <?# if($item['status']) {#?>
			  <font color="red">已标记</font>
		      <?#}?>
		      <input type="checkbox" value="<?#=$item['userid'];#?>">
		      <a href="/admin/live/monitor/snapshot/log.html?userid=<?#=$item['userid'];#?>" target="_blank">
			    [<?#=$item['starlv'];#?>][<?#=$item['author'];#?>][<?#=$item['title'];#?>]
			  </a>
			</p>
		  </div>
		  <?#}
		  }else {#?>
		  <div class="alert alert-info" role="alert">没有查询结果</div>
		  <?#}?>
		</div>
    </div>
    <ul id="paging" style="margin:0 10px -10px 10px;"></ul> <span style="font-size:15px;">共<?#=$totalPages;#?>页,总共<?#=$total;#?>条</span>
    <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
    <script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="/static/plugins/bootstrap-paginator.js"></script>
    <script type='text/javascript'>
        var page = 1;
	    var getdata = function(page) {
	    	$.post('<?#=$dourl;#?>', {page:page, key:'<?#=$key;#?>', status:'<?#=$status;#?>'}, function(data) {
	            $("#list").html(data);
	        });
	    }
        var options = {
        	bootstrapMajorVersion : 3,
            currentPage: 1,
            totalPages: <?#=$totalPages;#?>,
            numberOfPages: 10,
            itemTexts: function(type, page, current) {
                switch (type) {
	                case "first":
	                    return "首页";
	                case "prev":
	                    return "上一页";
	                case "next":
	                    return "下一页";
	                case "last":
	                    return "末页";
	                case "page":
	                    return page;
                }
            }, onPageClicked: function (event, originalEvent, type, page) {
            	getdata(page);
            	window.page = page;
            },
        }
        $('#paging').bootstrapPaginator(options);
        
        //设为可疑
        $('#set').click(function(){
        	deal(1);
        });
        //取消可疑
        $('#cancel').click(function(){
        	deal(0);
        });
        var deal = function(status) {
        	var idarr = new Array();
        	$('input[type="checkbox"]:checked').each(function(){
        		idarr.push($(this).val()); 
       		});
        	if(idarr.length < 1){
        		alert('no choice');
        		return;
        	}
            if(confirm('Are you sure?')) {
            	var ids = idarr.join(',');
            	$.post('<?#=$doset;#?>', {ids:ids, status:status}, function(data) {
            		getdata(page);
    	        });
            }
	    } 
        window.setInterval(function(){
        	window.location.href='<?#=$baseurl;#?>';
        }, 60000);
    </script>
  </body>
</html>